package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.Vector;

public class GetCategories {
	
	private Vector<String> categories;
	
	
	public GetCategories(){}
	
	
	
	
	public Vector<String> getAll()
	{
		Vector<String> categories =new Vector<String>();		
        SQLConnection sc=new SQLConnection();
        this.categories = new Vector<String>();
		
        	try {			
        		PreparedStatement ps = sc.getConnection().prepareStatement("SELECT DISTINCT icategory FROM item;");	

        		ResultSet rs=ps.executeQuery();	

        		ResultSetMetaData rsmd = rs.getMetaData();
        		
        		 while(rs.next())
        	        {   
        	         for(int col = 1; col <= rsmd.getColumnCount(); col++) 
        	         	{                      	                	               
        	                 this.categories.add(rs.getString(col));
        	         	}//for
        	        }//while
        		 ps.close();
        		 rs.close();
        		 sc.getConnection().close();
        		
        		} catch (SQLException e) {
        			// TODO Auto-generated catch block
        			e.printStackTrace();
        		}
        		return this.categories;
        	
        
        
}
}
